using System;
using System.Collections.Generic;
using System.Linq;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.Graphics;

using TimeWar.Engine;

// TODO: replace this with the type you want to read.
using TRead = TimeWar.Engine.LevelConfig;

namespace TimeWar.ContentProcessor.Config
{
    /// <summary>
    /// This class will be instantiated by the XNA Framework Content
    /// Pipeline to read the specified data type from binary .xnb format.
    /// 
    /// Unlike the other Content Pipeline support classes, this should
    /// be a part of your main game project, and not the Content Pipeline
    /// Extension Library project.
    /// </summary>
    public class LevelReader : ContentTypeReader<TRead>
    {


        protected override TRead Read(ContentReader input, TRead existingInstance)
        {
            // TODO: read a value from the input ContentReader.

            existingInstance = new LevelConfig();
            existingInstance.Name = input.ReadString();
            existingInstance.TerrainAssetName = input.ReadString();
            existingInstance.TerrainTexture = input.ReadString();
            existingInstance.TerrainColourEffect = input.ReadString();
            existingInstance.SkyAssetName = input.ReadString();
            existingInstance.HeightMap = input.ReadString();
            existingInstance.TerrainScaleX = input.ReadDouble();
            existingInstance.TerrainScaleY = input.ReadDouble();
            existingInstance.TerrainScaleZ = input.ReadDouble();

            existingInstance.SkyBack = input.ReadString();
            existingInstance.SkyFront = input.ReadString();
            existingInstance.SkyLeft = input.ReadString();
            existingInstance.SkyRight = input.ReadString();
            existingInstance.SkyTop = input.ReadString();
            existingInstance.SkyTextureEffect = input.ReadString();
            existingInstance.SkyPositionColourEffect = input.ReadString();
            existingInstance.SkyScaleX = input.ReadDouble();
            existingInstance.SkyScaleY = input.ReadDouble();
            existingInstance.SkyScaleZ = input.ReadDouble();

            existingInstance.CameraOffset = input.ReadVector3();
            existingInstance.CameraNearClip = input.ReadDouble();
            existingInstance.CameraFarClip = input.ReadDouble();

            return existingInstance;
        }

    }
}
